Find the next previous palindrome of NΒΆ

Write a python program to find the next previous palindrome of a specified number.
def previous_palindrome(N):
    for x in range(N-1, 0, -1):
        if str(x) == str(x)[::-1]:
            return x

# test
print(previous_palindrome(99))      # 88
print(previous_palindrome(1221))    # 1111